<?php

namespace co2_OS;

function autoload($class)

{
	if(preg_match('/^co2_OS\\\apps\\\/',$class))
	
	{
		$file=preg_replace('/^co2_OS\\\apps\\\/','',$class);
		
		$file=preg_replace('/\\\/','/',$file);
		
		$file=main::getSysVar('apps').'/'.$file.'.php';

		if(!file_exists($file))
		throw new \co2\Exception('failed to autoload '.$class);
		
		require_once $file;
		
		if(!class_exists($class))
		throw new \co2\Exception('class not found: '.$class.' in file '.$file);
	}
}
